package com.music.order.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.music.common.core.utils.poi.ExcelUtil;
import com.music.common.core.web.controller.BaseController;
import com.music.common.core.web.domain.AjaxResult;
import com.music.common.core.web.page.TableDataInfo;
//import com.music.common.log.annotation.Log;
//import com.music.common.log.enums.BusinessType;
import com.music.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.music.order.domain.OrderMusic;
import com.music.order.service.OrderMusicService;

/**
 * 订单音乐列表Controller
 * 
 * @author ruoyi
 * @date 2024-10-22
 */
@RestController
@RequestMapping("/ordermusic")
public class OrderMusicController extends BaseController
{
    @Autowired
    private OrderMusicService orderMusicService;

    /**
     * 查询订单音乐列表列表
     */
    @RequiresPermissions("order:ordermusic:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderMusic orderMusic)
    {
        startPage();
        List<OrderMusic> list = orderMusicService.selectOrderMusicList(orderMusic);
        return getDataTable(list);
    }

    /**
     * 导出订单音乐列表列表
     */
    @RequiresPermissions("order:ordermusic:export")
//    @Log(title = "订单音乐列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderMusic orderMusic)
    {
        List<OrderMusic> list = orderMusicService.selectOrderMusicList(orderMusic);
        ExcelUtil<OrderMusic> util = new ExcelUtil<OrderMusic>(OrderMusic.class);
        util.exportExcel(response, list, "订单音乐列表数据");
    }

    /**
     * 获取订单音乐列表详细信息
     */
    @RequiresPermissions("order:ordermusic:query")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return success(orderMusicService.selectOrderMusicByOrderId(orderId));
    }

    /**
     * 新增订单音乐列表
     */
    @RequiresPermissions("order:ordermusic:add")
//    @Log(title = "订单音乐列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderMusic orderMusic)
    {
        return toAjax(orderMusicService.insertOrderMusic(orderMusic));
    }

    /**
     * 修改订单音乐列表
     */
    @RequiresPermissions("order:ordermusic:edit")
//    @Log(title = "订单音乐列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderMusic orderMusic)
    {
        return toAjax(orderMusicService.updateOrderMusic(orderMusic));
    }

    /**
     * 删除订单音乐列表
     */
    @RequiresPermissions("order:ordermusic:remove")
//    @Log(title = "订单音乐列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(orderMusicService.deleteOrderMusicByOrderIds(orderIds));
    }
}
